package yunquan.wang.base.event;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;

public class LoggingEventHandler extends YunquanEventListener {
	   private Log eventLogger = this.logger;
	   private String logCategory;
	   
	public String getLogCategory() {
		return logCategory;
	}

	public void setLogCategory(String logCategory) {
		this.logCategory = logCategory;
	}

	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		if(logCategory!=null)
		{
		       this.eventLogger = LogFactory.getLog(logCategory);
		}
		if (this.eventLogger.isInfoEnabled()) {
		    this.eventLogger.info(event.toString());
		}
	}
    
}